home *** CD-ROM | disk | FTP | other *** search
- head 1.6;
- branch ;
- access ;
- symbols sprited:1.6.1;
- locks ; strict;
- comment @ * @;
-
-
- 1.6
- date 91.09.23.18.22.55; author mottsmth; state Exp;
- branches 1.6.1.1;
- next 1.5;
-
- 1.5
- date 88.07.29.18.54.36; author ouster; state Exp;
- branches ;
- next 1.4;
-
- 1.4
- date 88.07.29.18.39.31; author ouster; state Exp;
- branches ;
- next 1.3;
-
- 1.3
- date 88.07.29.17.40.54; author ouster; state Exp;
- branches ;
- next 1.2;
-
- 1.2
- date 88.06.21.17.25.17; author ouster; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 88.06.19.14.32.12; author ouster; state Exp;
- branches ;
- next ;
-
- 1.6.1.1
- date 91.10.02.12.48.20; author kupfer; state Exp;
- branches ;
- next ;
-
-
- desc
- @@
-
-
- 1.6
- log
- @Special case for wait3: return 0 if no children have exited,
- rather than return -1.
- @
- text
- @/*
- * wait.c --
- *
- * Procedure to map from Unix wait system call to Sprite.
- *
- * Copyright (C) 1986 Regents of the University of California
- * All rights reserved.
- */
-
- #ifndef lint
- static char rcsid[] = "$Header: /sprite/src/lib/c/unixSyscall/RCS/wait.c,v 1.5 88/07/29 18:54:36 ouster Exp Locker: mottsmth $ SPRITE (Berkeley)";
- #endif not lint
-
- #include <sprite.h>
- #include <proc.h>
- #include <spriteTime.h>
-
- #include "compatInt.h"
-
- #include <sys/wait.h>
- #include <sys/time.h>
- #include <sys/resource.h>
- #include <status.h>
-
-
- /*
- *----------------------------------------------------------------------
- *
- * wait --
- *
- * Procedure to map from Unix wait system call to Sprite Proc_Wait.
- *
- * Results:
- * If wait returns due to a stopped or terminated child process,
- * the process ID of the child is returned to the calling process.
- * In addition, if statusPtr is non-null then fields in *statusPtr
- * will be set to contain the exit status of the child whose process
- * ID is returned.
- *
- * Otherwise, UNIX_ERROR is returned and errno is set to indicate
- * the error.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
- int
- wait(statusPtr)
- union wait *statusPtr;
- {
- ReturnStatus status; /* result returned by Proc_Wait */
- int pid; /* process ID of child */
- int reason; /* reason child exited */
- int childStatus; /* returnStatus of child */
- int subStatus; /* additional signal status */
- int unixSignal;
-
- status = Proc_Wait(0, (int *) NULL, PROC_WAIT_BLOCK, &pid, &reason,
- &childStatus, &subStatus, (Proc_ResUsage *) NULL);
- if (status != SUCCESS) {
- errno = Compat_MapCode(status);
- return(UNIX_ERROR);
- } else {
- if (statusPtr != NULL) {
- statusPtr->w_status = 0;
- if (reason == PROC_TERM_SUSPENDED) {
- (void)Compat_SpriteSignalToUnix(childStatus, &unixSignal);
- statusPtr->w_stopval = WSTOPPED;
- statusPtr->w_stopsig = unixSignal;
- } else if (reason == PROC_TERM_SIGNALED ||
- reason == PROC_TERM_RESUMED) {
- (void)Compat_SpriteSignalToUnix(childStatus, &unixSignal);
- statusPtr->w_termsig = unixSignal;
- /* NEED TO HANDLE coredump FIELD */
- } else {
- statusPtr->w_retcode = childStatus;
- }
- }
- return((int) pid);
- }
- }
-
-
- /*
- *----------------------------------------------------------------------
- *
- * wait3 --
- *
- * Procedure to map from Unix wait3 system call to Sprite Proc_Wait.
- *
- * Results:
- * If wait returns due to a stopped or terminated child process,
- * the process ID of the child is returned to the calling process.
- * In addition, if statusPtr is non-null then fields in *statusPtr
- * will be set to contain the exit status of the child whose process
- * ID is returned.
- *
- * Otherwise, UNIX_ERROR is returned and errno is set to indicate
- * the error.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
- wait3(statusPtr, options, unixRusagePtr)
- union wait *statusPtr;
- int options;
- struct rusage *unixRusagePtr;
- {
- Proc_ResUsage spriteRusage;
- ReturnStatus status; /* result returned by Proc_Wait */
- int pid; /* process ID of child */
- int reason; /* reason child exited */
- int childStatus; /* returnStatus of child */
- int subStatus; /* additional signal status */
- int flags = 0;
-
- if (!(options & WNOHANG)) {
- flags |= PROC_WAIT_BLOCK;
- }
- if (options & WUNTRACED) {
- flags |= PROC_WAIT_FOR_SUSPEND;
- }
-
- status = Proc_Wait(0, (int *) NULL, flags, &pid, &reason,
- &childStatus, &subStatus, &spriteRusage);
- if (status != SUCCESS) {
- if ((status == PROC_NO_EXITS) && (options & WNOHANG)) {
- return(0);
- }
- errno = Compat_MapCode(status);
- return(UNIX_ERROR);
- } else {
- if (statusPtr != NULL) {
- int unixSignal;
- statusPtr->w_status = 0;
- if (reason == PROC_TERM_SUSPENDED) {
- (void)Compat_SpriteSignalToUnix(childStatus, &unixSignal);
- statusPtr->w_stopval = WSTOPPED;
- statusPtr->w_stopsig = unixSignal;
- } else if (reason == PROC_TERM_SIGNALED ||
- reason == PROC_TERM_RESUMED) {
- (void)Compat_SpriteSignalToUnix(childStatus, &unixSignal);
- statusPtr->w_termsig = unixSignal;
- /* NEED TO HANDLE coredump FIELD */
- } else {
- statusPtr->w_retcode = childStatus;
- }
- }
- if (unixRusagePtr != NULL) {
- /*
- * Return the total time used by the process and all its children.
- */
- Time totalKTime;
- Time totalUTime;
-
- bzero((char *) unixRusagePtr, sizeof(*unixRusagePtr));
- Time_Add(spriteRusage.userCpuUsage, spriteRusage.childUserCpuUsage,
- &totalUTime);
- Time_Add(spriteRusage.kernelCpuUsage,
- spriteRusage.childKernelCpuUsage, &totalKTime);
- unixRusagePtr->ru_utime.tv_sec = totalUTime.seconds;
- unixRusagePtr->ru_utime.tv_usec = totalUTime.microseconds;
- unixRusagePtr->ru_stime.tv_sec = totalKTime.seconds;
- unixRusagePtr->ru_stime.tv_usec = totalKTime.microseconds;
- unixRusagePtr->ru_nvcsw = spriteRusage.numWaitEvents;
- unixRusagePtr->ru_nivcsw = spriteRusage.numQuantumEnds;
- }
- return((int) pid);
- }
- }
- @
-
-
- 1.6.1.1
- log
- @Initial branch for Sprite server.
- @
- text
- @d11 1
- a11 1
- static char rcsid[] = "$Header: /sprite/src/lib/c/unixSyscall/RCS/wait.c,v 1.6 91/09/23 18:22:55 mottsmth Exp $ SPRITE (Berkeley)";
- @
-
-
- 1.5
- log
- @Lint.
- @
- text
- @d11 1
- a11 1
- static char rcsid[] = "$Header: wait.c,v 1.4 88/07/29 18:39:31 ouster Exp $ SPRITE (Berkeley)";
- d131 3
- @
-
-
- 1.4
- log
- @Lint.
- @
- text
- @d11 1
- a11 1
- static char rcsid[] = "$Header: wait.c,v 1.3 88/07/29 17:40:54 ouster Exp $ SPRITE (Berkeley)";
- d60 1
- a60 1
- &childStatus, &subStatus, (int *) NULL);
- @
-
-
- 1.3
- log
- @Lint.
- @
- text
- @d11 1
- a11 1
- static char rcsid[] = "$Header: wait.c,v 1.2 88/06/21 17:25:17 ouster Exp $ SPRITE (Berkeley)";
- d53 1
- a53 1
- Proc_PID pid; /* process ID of child */
- d59 2
- a60 2
- status = Proc_Wait(0, (Proc_PID *) NULL, PROC_WAIT_BLOCK, &pid, &reason,
- &childStatus, &subStatus, (Proc_PID *) NULL);
- d115 1
- a115 1
- Proc_PID pid; /* process ID of child */
- d128 1
- a128 1
- status = Proc_Wait(0, (Proc_PID *) NULL, flags, &pid, &reason,
- d157 1
- a157 1
- bzero(unixRusagePtr, sizeof(*unixRusagePtr));
- @
-
-
- 1.2
- log
- @Various changes to make code compile under new library.
- @
- text
- @d11 1
- a11 1
- static char rcsid[] = "$Header: wait.c,v 1.1 88/06/19 14:32:12 ouster Exp $ SPRITE (Berkeley)";
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d11 1
- a11 1
- static char rcsid[] = "$Header: wait.c,v 1.12 88/04/27 19:16:52 nelson Exp $ SPRITE (Berkeley)";
- d14 3
- a16 3
- #include "sprite.h"
- #include "proc.h"
- #include "/sprite/lib/include/time.h"
- @
-